import React, { Component } from 'react'
import { Select } from 'antd'
import {getHeroPosi} from '../../utils/api'
const { Option } = Select
export default class CateSelect extends Component {
    constructor(props) {
        super(props)
        this.state = {
            cates: [
               
            ]
        }
    }
    componentDidMount(){
        getHeroPosi().then(arr=>{
            console.log('222',arr)
            this.setState({
                cates:arr
            })
        })
    }
    createSelect() {
        let { cates } = this.state
        return cates.map(ele => (
            <Option key={ele._id} value={ele.position}>{ele.position}</Option>
        ))

    }
    cateChange(value) {
        this.props.onChange(value)
    }
    render() {
        let { value } = this.props
        console.log('11',value)
        console.log('2222',this.props)
        value = value || ''
        return (
            <div >
                <Select style={{ width: '100%' }} value={value} onChange={this.cateChange.bind(this)}>
                    {this.createSelect()}
                </Select>
            </div>
        )
    }
}
